
export default class ButtonAction {
    constructor(comp) {
        this.comp = comp;
    }

    // 第一次进页面的按钮状态
    initPageButton = () => {
        const {props} = this.comp;
        const {
            button
        } = props;
        
        button.setButtonVisible({
            edit: false,
            save: false,
            cancel: false    
        });
        button.setButtonDisabled({
    
        });
    }

    // 展示查询弹窗
    showSearchModal = () => {
        const {props} = this.comp;
        const {search} = props;

        search.openAdvSearch('query', true);
    }

    // 人力组织改变
    changeOrg = (value) => {
        const {props, action} = this.comp;
        const {
            dispatch,
            button,
            emp
        } = props;
        if(value.refpk && emp.pageStatus === 'browse') {
            button.setButtonVisible({
                edit: true 
            });
            this.pubSub.publish('getMainTableData', {
                pk_org: value.refpk
            });
        }
        // else if(){

        // }
        else{
            button.setButtonVisible({
                edit: false
            });
        }   
        dispatch({
            type: 'emp/update',
            payload: {
                orgValue: value,
                tabKey: 'entry'
            }
        });
    }

    // 新增页面头部按钮点击处理
    addHeaderClick = (btnCode) => {
        const {action, props} = this.comp;
        const {form} = props;
        return (props, bCode) => {
            if(btnCode === 'edit_status') {
                if(bCode === 'edit') {
                   action.tableAct.toEditStatus();  
                } 
            }
            else if(btnCode === 'browse_status') {
                if(bCode === 'save') {
                    action.tableAct.openSaveBox();
                }
                else if(bCode === 'cancel') {
                    action.tableAct.cancelSaveBox();
                }
            }
        }
    }

}